import java.util.Scanner;

// 直接拆分计数就行
public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int L = in.nextInt();
            int R = in.nextInt();
            int totalCount = 0;
            for (int i = L; i <= R; i++) {
                totalCount += countTwo(i);
            }
            System.out.println(totalCount);
        }
    }

    // 统计数字 x 中 2 的个数
    public static int countTwo(int x) {
        int count = 0;
        while (x > 0) {
            if (x % 10 == 2) { // 检查当前最低位
                count++;
            }
            x /= 10; // 去掉最低位
        }
        return count;
    }
}